using System;
using OhioState.AssetManaged;

namespace OhioState.Graphics.Proxy
{    
    /// <summary>
    /// Texture Proxy class that inherits from ITexture
    /// </summary>
    [Serializable()]
    public class TextureProxy : SharedAsset, ITexture
    {
        /// <summary>
        /// Stores the default texel format
        /// </summary>
        protected static TexelFormat DefaultTexelFormat = new TexelFormat();
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="name">name</param>
        public TextureProxy(string name)
            : this(name, 512, 512, 1, DefaultTexelFormat)
        {
            _width = 512;
            _height = 512;
            _depth = 1;
            _type.Type = ByteFormat.BYTE;
            _type.Format = ImageFormat.RGBA;
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="name">name</param>
        /// <param name="width">width</param>
        /// <param name="height">height</param>
        /// <param name="depth">depth</param>
        public TextureProxy(string name, int width, int height, int depth) : base(name)
        {
            _width = width;
            _height = height;
            _depth = depth;
            _type.Type = ByteFormat.BYTE;
            _type.Format = ImageFormat.RGBA;
        }

       
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="name">name</param>
        /// <param name="width">width</param>
        /// <param name="height">height</param>
        /// <param name="depth">depth</param>
        /// <param name="type">type</param>
        public TextureProxy(string name, int width, int height,int depth, TexelFormat type)
            : base(name)
        {
            _width = width;
            _height = height;
            _depth = depth;
            _type = type;
        }

        /// <summary>
        /// width of texture
        /// </summary>
        protected int _width;
        /// <summary>
        /// Get Set accessors for Width
        /// </summary>
        public int Width
        {
            get { return _width; }
            set { _width = value; }
        }
        /// <summary>
        /// height of texture
        /// </summary>
        protected int _height;
        /// <summary>
        /// Get Set Accessors for Height
        /// </summary>
        public int Height
        {
            get { return _height; }
            set { _height = value; }
        }
        /// <summary>
        /// Depth of texture
        /// </summary>
        protected int _depth;
        /// <summary>
        /// Get Set Accessors for depth
        /// </summary>
        public int Depth
        {
            get { return _depth; }
            set { _depth = value; }
        }
        /// <summary>
        /// Texture type
        /// </summary>
        protected TexelFormat _type;
        /// <summary>
        /// Get Set Accessors for TexelType
        /// </summary>
        public TexelFormat TexelType
        {
            get { return _type; }
            set { _type = value; }
        }

        /// <summary>
        /// Implementation of ITexture bind method
        /// </summary>
        public virtual void bind()
        {

        }
        /// <summary>
        /// Implementation of ITexture unbind method
        /// </summary>
        public virtual void unbind()
        {

        }

        /// <summary>
        /// Clone a given texture object
        /// </summary>
        /// <param name="tex">input texture</param>
        /// <returns>cloned texture</returns>
        public virtual TextureProxy Clone(TextureProxy tex)
        {
            
            TextureProxy texClone = new TextureProxy(tex.Name, tex.Width, tex.Height,tex.Depth, tex.TexelType);
            return texClone;
        }
        /// <summary>
        /// Clone texture
        /// </summary>
        /// <returns></returns>
        public virtual TextureProxy Clone()
        {
            TextureProxy texClone = new TextureProxy("");
            texClone.Width = this.Width;
            texClone.Height = this.Height;
            texClone.Depth = this.Depth;
            texClone.TexelType = this.TexelType;
            texClone.Name = this.Name + "Clone";
            return texClone;
        }
    }
}
